﻿using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using Deepcode.ValidationSample.Controllers;

namespace Deepcode.ValidationSample.Models
{
	public class BookViewModel
	{
		[Required(ErrorMessage = "Book title is required")]
		[DisplayName("Book title:")]
		public string Title{ get; set; }

		[Required(ErrorMessage = "Author must be specified for a book")]
		[IsNotTonyJohnson(ErrorMessage = "Sorry, we do NOT publish books for Tony Johnson :)")]
		[SpecialAuthorName(ClientSideName="Bill Gates", ServerSideName="Richard Branson", ErrorMessage="Those guys rock, but we can't afford to publish their books!")]
		public string Author{ get; set; }

		[Required(ErrorMessage = "ISBN Number is a mandatory field")]
		[RegularExpression("^[a-z0-9A-Z]{8}$", ErrorMessage = "ISBN number is 8 alpha numeric digits, this ISBN is not valid")]
		[DisplayName("ISBN Number:")]
		public string IsbnNumber { get; set; }

		public string Synopsis { get; set; }

		[Range(5.0d, 15.0d, ErrorMessage="Unusual price entered! Try a valid between 5.00 and 15.00")]
		public decimal Price{ get; set; }
	}
}